<?php include("header.inc.php") ?>
<?php include("navigation.inc.php")?>       
<?php include("left.inc.php")?>       
<div id="mainContent" class="grid_7">


    <?php
                        $display = 2;
                        if (isset($_GET['page']) && (int)$_GET['page']) {
                            $page = $_GET['page'];	
                        } else {                   
                            $sql = "SELECT COUNT(idhoatdonghocsinh) FROM hoatdonghocsinh WHERE status = 1";
                            $query = mysql_query($sql) or die("Error query count ".mysql_error($conn));
                            $rows = mysql_fetch_array($query);
                            $record = $rows[0];
                            if ($record > $display) {
                                $page = ceil($record/$display);	
                            } else {
                                $page = 1;	
                            }
                            
                            $start = (isset($_GET['start']) && (int)$_GET['start'])?$_GET['start']:0;
                            $sql2 = "SELECT * FROM hoatdonghocsinh WHERE status = 1 ORDER BY tenlop ASC LIMIT $start,$display";
                            $result = mysql_query($sql2) or die("Error query lop ".mysql_error($conn));
                            while ($row = mysql_fetch_array($result)) {
      ?>
      <div id="tintuc" class="grid_7">
    	<div id="tieude" class="grid_7">
			<a href = "lop.php?id=<? echo $row['idhoatdonghocsinh'];?>&page=1"> LỚP <?php echo $row['tenlop']?> </a>        	
        </div>
        <div id="xemchitiet" class="grid_7">
       	<a href = "lop.php?id=<?php echo $row['idhoatdonghocsinh'];?>&page=1"> Xem Chi Tiết >> </a>        	
        </div>
        
    </div>   
    <?php 
							}
						}
							?>
      <div class="pagelist">
         <ul>
                    <?php						
					if($page > 1) {
						$next = $start + $display;
						$previous = $start - $display;
						$current = ($start/$display) + 1;				
						if ($current != 1) {
							echo "<li><a href='hocsinh.php?start=$previous'>Quay Lại</a></li>";	
						} 
						for ($i=1;$i<=$page;$i++){
							if($i != $current) {
								echo "<li><a href='hocsinh.php?start=".($display*($i-1))."'>$i</a></li>";	
							} else {
								echo "<li class='current'>$i</li>";		
							}
						}
						if ($current != $page){
							echo "<li><a href='hocsinh.php?start=$next'>Tiếp</a></li>";	
						}
					}
					?>
         </ul>
      </div>
   
</div>
     
<?php include("right.inc.php")?>  
<?php include("footer.inc.php")?>  

